/**
 * 
 */
package JUnitTests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.omg.PortableInterceptor.SUCCESSFUL;

import Framework.*;
/**
 * @author Pierre-Olivier
 *
 */
public class TestPlayer {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception 
	{
		testGetSetName();
		testGetSetScore();
		testAddToScore();
		testConstructor();
	}

	/**
	 * Test method for {@link Framework.Player#Player(java.lang.Object)}.
	 */
	@Test
	public final void testGetSetName() 
	{
		Player p = new Player("asdf");
		p.setName("name");
		if (p.getName() != "name")
			fail("Get or Set name failed");	
	}

	/**
	 * Test method for {@link Framework.Player#Player(java.lang.Object)}.
	 */
	@Test
	public final void testGetSetScore() 
	{
		Player p = new Player("asdf");
		p.setScore(24);
		if (p.getScore() != 24)
			fail("Get or Set score failed");
		p.setScore(-1);
		if (p.getScore() != -1)
			fail("Get or Set score failed");
		p.setScore(0);
		if (p.getScore() != 0)
			fail("Get or Set score failed");
	}

	/**
	 * Test method for {@link Framework.Player#Player(java.lang.Object)}.
	 */
	@Test
	public final void testAddToScore() 
	{
		Player p = new Player("asdf");
		
		p.addToScore(24);
		if (p.getScore() != 24)
			fail("AddToScore failed");	
		
		p.addToScore(2);
		if (p.getScore() != (24 + 2))
			fail("AddToScore failed");
		
		p.addToScore(11112);
		if (p.getScore() != (24 + 2 + 11112))
			fail("AddToScore failed");
		
		p.addToScore(-21112);
		if (p.getScore() != (24 + 2 + 11112 + (-21112)))
			fail("AddToScore failed");
	}

	/**
	 * Test method for {@link Framework.Player#Player(java.lang.Object)}.
	 */
	@Test
	public final void testConstructor() 
	{
		Player p = new Player("asdf");
		
		if (p == null || p.getName() != "asdf")
			fail("Constructor failed");		
	}

}
